package chapter4;

import java.util.Properties;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.junit.Before;

public abstract class AbstractProducer {

  protected Properties properties = new Properties();

  @Before
  public void before() {
    properties.put("bootstrap.servers", "localhost:9092,localhost:9093,localhost:9094");
    properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    properties.put("acks", "-1");
    properties.put("retries", 3);
    properties.put("batch.size", 323840);
    properties.put("linger.ms", 10);
    properties.put("buffer.memory", 33554432);
    properties.put("max.block.ms", 3000);
  }

  protected void printMetadata(RecordMetadata metadata) {
    System.out.println(
      "topic: " + metadata.topic() + ", partition: " + metadata.partition() + ", offset: "
        + metadata.offset());
  }
}
